package com.cjx.yuanshenstartforumbackend.interceptor;

import com.cjx.yuanshenstartforumbackend.utils.UserHolder;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description 登录拦截器-拦截未登录的请求
 * @Author cjx
 * @Date 2023/12/22 21:18
 **/
public class LoginInterceptors implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //判断本地线程中是否有用户对象，没有代表未登录，直接拦截
       /* if (UserHolder.getUser() == null){
            //设置状态码
            response.setStatus(401);
            return false;
        }*/
        return true;
    }
}
